var express = require('express');
var app = express();
var db = require('./model/db')
var bodyParser = require('body-parser');
var db = require('./model/db.js');
//这些设定好之后post请求了就有了req.body了
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())

app.set('view engine', 'ejs');
app.use(express.static('./public'));

app.all('*', function(req, res, next) {  
    res.header("Access-Control-Allow-Origin", "*");  
    res.header("Access-Control-Allow-Headers", "X-Requested-With");  
    res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");  
    res.header("X-Powered-By",' 3.2.1')  
    res.header("Content-Type", "application/json;charset=utf-8");  
    next();  
});  

app.get('/du',function(req,res){
        console.log('我进来了')
        res.send('进来了')
})  

app.post('/du',function(req,res){
 
       res.send(req.body.name)
})  

app.listen(3001);